package com.ep.modules.app.controller;

import com.ep.common.annotation.SysLog;
import com.ep.common.utils.PageUtils;
import com.ep.common.utils.R;
import com.ep.common.validator.ValidatorUtils;
import com.ep.modules.app.entity.AppVoucherEntries;
import com.ep.modules.app.service.AppVoucherEntriesService;
import java.util.Map;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app/voucher_entries")
public class AppVoucherEntriesController {
    @Autowired
    private AppVoucherEntriesService appVoucherEntriesService;

    @GetMapping("/list")
    public R list(Map<String, Object> params) {
        PageUtils page = appVoucherEntriesService.queryPage(params);
        return R.ok().put("page", page);
    }

    @GetMapping("/info/{id}")
    public R info(@PathVariable Long id) {
        AppVoucherEntries appvoucherentries = appVoucherEntriesService.getById(id);
        return R.ok().put("appvoucherentries", appvoucherentries);
    }

    @SysLog("保存AppVoucherEntries")
    @PostMapping("/save")
    public R save(@RequestBody AppVoucherEntries appvoucherentries) {
        ValidatorUtils.validateEntity(appvoucherentries);
        appVoucherEntriesService.save(appvoucherentries);
        return R.ok();
    }

    @SysLog("修改AppVoucherEntries")
    @PostMapping("/update")
    public R update(@RequestBody AppVoucherEntries appvoucherentries) {
        ValidatorUtils.validateEntity(appvoucherentries);
        appVoucherEntriesService.update(appvoucherentries);
        return R.ok();
    }

    @SysLog("删除AppVoucherEntries")
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids) {
        appVoucherEntriesService.deleteBatch(ids);
        return R.ok();
    }
}